SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE dbo.[DnnProduct_GetModuleSettings]

@ModuleId int

AS
SELECT 
	SettingName,
	CASE WHEN LEFT(LOWER(dbo.DnnProduct_ModuleSettings.SettingValue), 6) = 'fileid' 
		THEN
			(SELECT Folder + FileName  
				FROM DnnProduct_Files 
				WHERE 'fileid=' + convert(varchar,dbo.DnnProduct_Files.FileID) = dbo.DnnProduct_ModuleSettings.SettingValue
			) 
		ELSE 
			dbo.DnnProduct_ModuleSettings.SettingValue  
		END 
	AS SettingValue
FROM dbo.DnnProduct_ModuleSettings 
WHERE  ModuleId = @ModuleId


GO
